<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<title><?php echo $site['name'] ?> - <?php echo $title; ?></title>
	<link rel="shortcut icon" href="<?php echo $site['url'] ?>favicon.ico" type="image/x-icon"/>
	<link rel="icon" href="<?php echo $site['url'] ?>favicon.ico" sizes="32x32">
	<link rel="stylesheet" type="text/css" href="<?php echo $site['style_url'] ?>master.css?v=<?php echo $site['version'] ?>">
	<link rel="stylesheet" type="text/css" href="<?php echo $site['style_url'] ?>ajax.css?v=<?php echo $site['version'] ?>">
	<?php foreach ($styles as $style) {?>
	<link rel="stylesheet" type="text/css" href="<?php echo $site['style_url'] . $style; ?>?v=<?php echo $site['version'] ?>">
	<?php } ?>

	<script type="text/javascript" src="<?php echo $site['script_url'] ?>jquery-1.7.2.min.js?v=<?php echo $site['version'] ?>"></script>
	<script type="text/javascript" src="<?php echo $site['script_url'] ?>jquery.customalert-0.1.js?v=<?php echo $site['version'] ?>"></script>
	<?php foreach ($scripts as $script) {?>
	<script type="text/javascript" src="<?php echo $site['script_url'] . $script; ?>?v=<?php echo $site['version'] ?>"></script>
	<?php } ?>
	<script type="text/javascript">
	var cfg = {
		url : "<?php echo $site['root']; ?>",
	}
	var site = {
		url : "<?php echo $site['root'] ?>",
		image : "<?php echo $site['images'] ?>",
		style : "<?php echo $site['style_url'] ?>",
	}
	$(function(){
		main.init.win();
		main.init.menu_animiate();
		main.init.quick_search();
		form.init();
		//form.checkbox._init();
		//form.checkbox._action();
		dataList.init();
		hack.dataList();
		$(window).resize(function(){
			main.init.win();
			tool.jump_box.draw();
		});
		$('#check-text').bind('click', function(){dataList.checkAll()});
		$('.js-date-decode').each(function(){
			$(this).text(tool.getLocalTime($(this).text()));
		})
	});

	/*********user_create_view.php / user_update_view.php********/
	var user = {
		composeRights : function($o){
			$o.each(function(){
				if (1 != $(this).val()) {
					if ('00' == $(this).val().substr(1)) {
						f = $(this).val().slice(0,1);
						$(this).parent().before('<div class="clear"></div>');
						$(this).attr('id', 'f-' + f).addClass('f');
					}
					else {
						$(this).addClass('c-f-' + f);
					}
				}
			})
		}
	}
	/*********user_create_view.php / user_update_view.php********/

	$(function(){
		user.composeRights($('.edit-right input[type=checkbox]'));
		$('.form-checkbox').click(function(){
			if ('checked' == $(this).children('input[type=checkbox]').attr('checked')) {
				if ('1' == $(this).children('input[type=checkbox]').val()) {
					$('.form-checkbox input[type=checkbox]').removeAttr('checked');
				}
				else {
					$(this).children('input[type=checkbox]').removeAttr('checked');
				}
				$('.form-checkbox input[type=checkbox]').eq(0).removeAttr('checked');
			}
			else {
				if ('1' == $(this).children('input[type=checkbox]').val()) {
					$('.form-checkbox input[type=checkbox]').attr('checked', 'checked')
				}
				else {
					$(this).children('input[type=checkbox]').attr('checked', 'checked');
				}
			}
			$('.f').each(function(){
				if (0 == $('.c-' + $(this).attr('id') + ':checked').length) {
					$(this).removeAttr('checked');
				}
				else {
					$(this).attr('checked', 'checked');
				}
			})
			if ( $('.form-checkbox input[type=checkbox]').length - 1 == $('.form-checkbox input[type=checkbox]:checked').length ) {
				$('.form-checkbox input[type=checkbox]').attr('checked', 'checked');
			}
			form.checkbox._action();
		})
	})

	//禁用退格键
	function banBackSpace(e){
    var ev = e || window.event;//获取event对象
    var obj = ev.target || ev.srcElement;//获取事件源
    var t = obj.type || obj.getAttribute('type');//获取事件源类型
    //获取作为判断条件的事件类型
    var vReadOnly = obj.readOnly;
    var vDisabled = obj.disabled;
    //处理undefined值情况
    vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
    vDisabled = (vDisabled == undefined) ? true : vDisabled;
    //当敲Backspace键时，事件源类型为密码或单行、多行文本的，
    //并且readOnly属性为true或disabled属性为true的，则退格键失效
    var flag1= ev.keyCode == 8 && (t=="password" || t=="text" || t=="textarea")&& (vReadOnly==true || vDisabled==true);
    //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效
    var flag2= ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea" ;
    //判断
    if(flag2 || flag1)return false;
	}
	//禁止退格键 作用于Firefox、Opera
	document.onkeypress=banBackSpace;
	//禁止退格键 作用于IE、Chrome
	document.onkeydown=banBackSpace;
	</script>
</head>
<body>
	<div id="header">
		<div id="header-content">
			<?php if (isset($header['username'])) { ?>
			<div id="header-menu">
				<ul>
					<?php foreach ($menus as $k => $menu) { ?>
					<li><a href="<?php echo $menu['url'] ?>" id="<?php echo $menu['id'] ?>"><?php echo $menu['name']; ?></a></li>
					<?php } ?>
				</ul>
				<div id="header-menu-show"></div>
			</div>
			<div id="header-menu-bg"></div>
			<div id="header-panel">
				<!--<div id="header-logout"><a href="<?php echo $site['root'] . 'login/' ?>"></a></div>-->
				<!--<div id="header-username"><a href="<?php echo $site['root'] ?>user/update/base/" target="_self"><?php echo $header['username']; ?></a></div>-->
				<div id="header-username"><a href="javascript:void(0)" target="_self"><?php echo $header['username']; ?></a></div>
				<div id="header-refresh" class="header-action"><a href="javascript:location.reload();"></a></div>
				<div id="header-goback" class="header-action"><a href="javascript:history.go(-1);"></a></div>
				<div id="header-quick-search-button" class="header-action"><a href="javascript:void(0);"></a></div>
				<div id="header-quick-search"><input type="text" name="goods_number" value="" /></div>
				<div id="header-quick-search-close" class="header-action hide"><a href="javascript:void(0);"></a></div>
				<div id="header-environment"><?php echo $site['environment']; ?></div>
				<div id="header-date"><?php echo date('Y年m月d日') ?></div>
			</div>
			<div id="header-hidden">
				<div id="user-panel">
					<a href="<?php echo $site['root'] ?>user/update/base/">个人中心</a>
					<a href="<?php echo $site['root'] . 'login/' ?>">注销</a>
				</div>
			</div>
			<?php  ?>
			<?php }else{ ?>
			<div id="header-login"><a href="<?php echo $site['root'] . 'login/' ?>">登录系统</a></div>
			<?php } ?>
		</div>
	</div>
	<div id="container">
		<?php if (isset($header['username']) && empty($error) && isset($sub_menus)) { ?>
		<div id="sub-menu">
			<ul>
				<?php foreach ($sub_menus as $menu) { ?>
				<?php if ($menu['index'] == 0) { ?>
				<li class="menu-line"></li>
				<?php }else{ ?>
				<li id="<?php echo isset($menu['id'])?$menu['id']:'' ?>"><a href="<?php echo $menu['url']; ?>" class="<?php if($sub_menu_index == $menu['index']){echo 'selected';} ?>" target="_self" /><?php echo $menu['name']; ?></a></li>
				<?php } ?>
				<?php } ?>
			</ul>
		</div>
		<div id="main">
		<?php } ?>